import React, { PureComponent } from 'react';
import { connect } from 'dva';
import { Input, Icon, message, Button, Form } from 'antd';
import styles from '../index.less';
import AuctionModal from '../../AuctionModal';
import CoverModal from '../../AuctionModal/CoverModal';

const FormItem = Form.Item;
const { TextArea } = Input;

@connect(state => ({

}))
@Form.create()

export default class BodyImgContent extends PureComponent {
  state = {
    text: '',
    index:0
  }
  componentDidMount() {
    const propsData = this.props.value.data;
    this.setState({
      text: propsData.text
    });
  }
  componentWillReceiveProps(nextProps) {
    
  }
  handlePushContent = () => {

    this.props.form.validateFieldsAndScroll(['title'], (err, val) => {
      if (!err) {
        if (this.props.onChange) this.props.onChange(this.props.index, {
            title: val
          })
      }
    })
  }
  handleChangeText = (e) => {
    this.setState({
      title: e.target.value
    })
  }
  handleOk = () => {
    if (this.props.onChange) this.props.onChange(this.state.title);
  }
  render() {
    const { props, value, operation, form: { getFieldDecorator }, moduleInfo } = this.props;
    console.log(this.props);
    return (
      <div>
        <div style={{marginBottom: 20}}>
          <p className={styles.lineTitleDefult} >
            {'请在下方添加文本'}
          </p>
          <div className={styles.InputBox}>
            <TextArea value={this.state.title} rows={4} onChange={this.handleChangeText}/>
          </div>
        </div>
        <div style={{ height: '40px' }}>
          <Button onClick={this.handleOk} type="primary" style={{ float: 'right' }}>确定</Button>
        </div>
      </div>
    );
  }
}
